
$(function(){
    getAllSender();

    $("#addReceiverBtn").click(function(){
        getPage($("#addSenderPageA")[0],ctx+'/user/addSenderPage.do');
    });

});

function getAllSender(){
    $('#manageGoodList>li').each(function(index){
       if(index>1)
        $(this).remove();
       if(index==1)
        $(this).show();
    });
    $.ajax({
        url:ctx+"/sender/list.do",
        data:{},
        success: function (data) {
            for(var i=0;i<data.length;i++){
                $('#manageGoodList').append('<li class="list_li c_txt">' +
                    '<div class="list_item_a">' +
                    data[i].name +
                    '</div>' +
                    '<div class="list_item_c">'+data[i].phone+'</div>' +
                    '<div class="list_item_f">' +
                    '<a class="del_item red_txt block" onclick="deletePlace('+data[i].id+')">删除</a>' +
                    '</div>' +
                    '<div class="clear"></div>' +
                    '</li>');

            }
            $('#manageGoodList>li:eq(1)').hide();
        }
    })

}

function deletePlace(id){
    $.ajax({
        url:ctx+"/sender/delete.do",
        data:{id:id},
        success: function (data) {
            getAllSender();
        }
    });
}